﻿<%@ Page Title="Administrative Actions" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AdminActions.aspx.cs" Inherits="Testify.Courses.Courses" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ MasterType VirtualPath="~/Site.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">

.dropDownSection
{
   float:right;
   width:230px;
}
.LinkButton
{
   text-transform:uppercase;
   font-size:larger;
   text-decoration:none;
   font-family: "Myriad Pro", open-sans, "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
}
.LinkButton:hover
{
   font-size:larger;
   font-family: "Myriad Pro", open-sans, "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
   color:White;
}

</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

   <asp:SqlDataSource ID="dsTermType" runat="server"
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT term_type_name, term_type_id
                                       FROM term_type 
                                      WHERE term_type_maint NOT LIKE 'D'
                                      ORDER BY term_type_id">
   </asp:SqlDataSource>  
   <asp:SqlDataSource ID="dsAllTermTypes" runat="server"
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT 1 as sort_by, term_type_id, term_type_name, term_type_maint
                                       FROM term_type 
                                      WHERE term_type_maint NOT LIKE 'D'
                               UNION SELECT 2 as sort_by, term_type_id, term_type_name, term_type_maint
                                       FROM term_type
                                      WHERE term_type_maint LIKE 'D' 
                                      ORDER BY sort_by, term_type_id"
                      UpdateCommand="BEGIN term_types.changeTermType(
                                           p_AdminID      =&gt; :p_AdminID,
                                           p_TermTypeID   =&gt; :term_type_id,
                                           p_TermTypeName =&gt; :term_type_name); END;" 
                      DeleteCommand="BEGIN term_types.deleteTermType(
                                           p_AdminID    =&gt; :p_AdminID,
                                           p_TermTypeID =&gt; :term_type_id); END;">
      <UpdateParameters>
         <asp:SessionParameter Name="p_AdminID" SessionField="UserID" />
         <asp:Parameter Name="term_type_id"/>
         <asp:Parameter Name="term_type_name" />
      </UpdateParameters>
      <DeleteParameters>
         <asp:SessionParameter Name="p_AdminID" SessionField="UserID" />
         <asp:Parameter Name="term_type_id"/>
      </DeleteParameters>
   </asp:SqlDataSource>
   <asp:SqlDataSource ID="dsTerm" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT t.term_id, rpad(tt.term_type_name, 20, '&nbsp;--------------------')  || ' ' || t.term_year as term_desc, term_start_date, term_end_date
                                       FROM term t
                                       JOIN term_type tt USING(term_type_id)
                                      WHERE term_maint NOT LIKE 'D'
                                        AND t.term_end_date &gt;= sysdate
                                      ORDER BY t.term_start_date">
   </asp:SqlDataSource>
   <asp:SqlDataSource ID="dsAllTerms" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT 1 as sort_by, term_type_name, term_year, term_maint, term_type_id, term_id, term_start_date, to_char(term_start_date, 'MM/dd/yyyy') as term_start, to_char(term_end_date, 'MM/dd/yyyy') as term_end
                                       FROM term t
                                       JOIN term_type tt USING(term_type_id)
                                      WHERE term_maint NOT LIKE 'D'
                                        AND t.term_end_date &gt; sysdate
                               UNION SELECT 2 as sort_by, term_type_name, term_year, term_maint, term_type_id, term_id, term_start_date, to_char(term_start_date, 'MM/dd/yyyy') as term_start, to_char(term_end_date, 'MM/dd/yyyy') as term_end
                                       FROM term t
                                       JOIN term_type tt USING(term_type_id)
                                      WHERE term_maint LIKE 'D'
                                        AND t.term_end_date &gt; sysdate
                               UNION SELECT 3 as sort_by, term_type_name, term_year, term_maint, term_type_id, term_id, term_start_date, to_char(term_start_date, 'MM/dd/yyyy') as term_start, to_char(term_end_date, 'MM/dd/yyyy') as term_end
                                       FROM term t
                                       JOIN term_type tt USING(term_type_id)
                                      WHERE t.term_end_date &lt;= sysdate
                                      ORDER BY sort_by, term_start_date, term_id" 
                      UpdateCommand="BEGIN terms.changeTerm(
                                           p_AdminID       =&gt; :p_AdminID,
                                           p_TermID        =&gt; :term_id,
                                           p_TermTypeID    =&gt; :term_type_id,
                                           p_TermStartDate =&gt; to_date(:term_start, 'MM/DD/YYYY'),
                                           p_TermEndDate   =&gt; to_date(:term_end,   'MM/DD/YYYY')); END;"
                      DeleteCommand="BEGIN terms.deleteTerm(
                                           p_AdminID    =&gt; :p_AdminID,
                                           p_TermID     =&gt; :term_id); END;">
      <UpdateParameters>
         <asp:SessionParameter  Name="p_AdminID" SessionField="UserID"/>
         <asp:Parameter Name="term_id" />
         <asp:Parameter Name="term_type_id" />
         <asp:Parameter Name="term_start" />
         <asp:Parameter Name="term_end" />
      </UpdateParameters>
      <DeleteParameters>
         <asp:SessionParameter Name="p_AdminID" SessionField="UserID" />
         <asp:Parameter Name="term_id"/>
      </DeleteParameters>
   </asp:SqlDataSource>
   <asp:SqlDataSource ID="dsCoursePrefix" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT course_type_id, course_type_prefix || ' - ' ||  course_type_name as course_desc 
                                       FROM course_type 
                                      WHERE course_type_maint NOT LIKE 'D'
                                      ORDER BY course_type_prefix" >
   </asp:SqlDataSource>
   <asp:SqlDataSource ID="dsAllCourseTypes" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT 1 as sort_by,course_type_id, course_type_prefix, course_type_name, course_type_maint
                                       FROM course_type 
                                      WHERE course_type_maint NOT LIKE 'D'
                               UNION SELECT 2 as sort_by, course_type_id, course_type_prefix, course_type_name, course_type_maint
                                       FROM course_type 
                                      WHERE course_type_maint LIKE 'D'
                                      ORDER BY sort_by, course_type_prefix"
                      UpdateCommand="BEGIN course_types.changeCourseType(
                                           p_AdminID          =&gt; :p_AdminID,
                                           p_CourseTypeID     =&gt; :course_type_id,
                                           p_CourseTypePrefix =&gt; :course_type_prefix,
                                           p_CourseTypeName   =&gt; :course_type_name);
                                     END;"
                      DeleteCommand="BEGIN course_types.deleteCourseType(
                                           p_AdminID      =&gt; :p_AdminID,
                                           p_CourseTypeID =&gt; :course_type_id);
                                     END;" >
      <UpdateParameters>
         <asp:SessionParameter  Name="p_AdminID" SessionField="UserID"/>
         <asp:Parameter Name="course_type_id" />
         <asp:Parameter Name="course_type_prefix" />
         <asp:Parameter Name="course_type_name" />
      </UpdateParameters>
      <DeleteParameters>
         <asp:SessionParameter Name="p_AdminID" SessionField="UserID" />
         <asp:Parameter Name="course_type_id"/>
      </DeleteParameters>
   </asp:SqlDataSource>
   <asp:SqlDataSource ID="dsAllSections" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT * FROM AllSections" 
                      UpdateCommand="BEGIN sections.changeSection(
                                           p_AdminID    =&gt; :p_AdminID,
                                           p_SectionID  =&gt; :section_id,
                                           p_TeacherID  =&gt; :user_id); END;"
                      DeleteCommand="BEGIN sections.deleteSection(
                                           p_AdminID    =&gt; :p_AdminID,
                                           p_SectionID  =&gt; :section_id); END;">
      <UpdateParameters>
         <asp:SessionParameter Name="p_AdminID" SessionField="UserID" />
         <asp:Parameter Name="section_id"/>
         <asp:Parameter Name="user_id"/>
      </UpdateParameters>
      <DeleteParameters>
         <asp:SessionParameter Name="p_AdminID" SessionField="UserID" />
         <asp:Parameter Name="section_id"/>
      </DeleteParameters>
   </asp:SqlDataSource>
   <asp:SqlDataSource ID="dsCourseName" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT course_id, crst.course_type_prefix || ' ' || crs.course_number || ' - ' || crs.course_name as course_desc 
                                       FROM course crs 
                                       JOIN course_type crst USING(course_type_id) 
                                      WHERE course_type_id = :v_CourseTypeID
                                        AND course_maint NOT LIKE 'D'
                                        AND course_type_maint NOT LIKE 'D'
                                      ORDER BY crst.course_type_prefix, crs.course_number, crs.course_name" >
      <SelectParameters>
         <asp:ControlParameter ControlID="ddlCourseType" Name="v_CourseTypeID" PropertyName="SelectedValue" />
      </SelectParameters>
   </asp:SqlDataSource>
   <asp:SqlDataSource ID="dsAllCourses" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT 1 as order_by, course_id, crst.course_type_prefix, course_type_id, crs.course_number, crs.course_name, crs.course_maint
                                       FROM course crs 
                                       JOIN course_type crst USING(course_type_id) 
                                      WHERE course_maint NOT LIKE 'D'
                               UNION SELECT 2 as order_by, course_id, crst.course_type_prefix, course_type_id, crs.course_number, crs.course_name, crs.course_maint
                                       FROM course crs 
                                       JOIN course_type crst USING(course_type_id) 
                                      WHERE course_maint LIKE 'D'  
                                      ORDER BY order_by, course_type_prefix, course_type_id, course_number, course_name, course_type_prefix, course_number, course_name" 
                      UpdateCommand="BEGIN courses.changeCourse(
                                           p_AdminID      =&gt; :p_AdminID, 
                                           p_CourseID     =&gt; :course_id,
                                           p_CourseName   =&gt; :course_name,
                                           p_CourseTypeID =&gt; :course_type_id,
                                           p_CourseNumber =&gt; :course_number); END;"
                      DeleteCommand="BEGIN courses.deleteCourse(
                                           p_AdminID  =&gt; :p_AdminID,
                                           p_CourseID =&gt; :course_id); END;">

      <UpdateParameters>
         <asp:SessionParameter Name="p_AdminID" SessionField="UserID" />
         <asp:Parameter Name="course_id"/>
         <asp:Parameter Name="course_name"/>
         <asp:Parameter Name="course_type_id"/>
         <asp:Parameter Name="course_number"/>
      </UpdateParameters>
      <DeleteParameters>
         <asp:SessionParameter Name="p_AdminID" SessionField="UserID" />
         <asp:Parameter Name="course_id"/>
      </DeleteParameters>
   </asp:SqlDataSource>
   <asp:SqlDataSource ID="dsTeacher" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT user_id as u_id, user_first_name || ' ' || user_last_name as name 
                                       FROM testify_user 
                                      WHERE user_type_id = 2
                                        AND user_maint NOT LIKE 'D'" >
   </asp:SqlDataSource>
   

   <asp:Table ID="tblButtons" runat="server" BackColor="#555555" class="actionButtons">
      <asp:TableRow>
         <asp:TableHeaderCell Width="100">
            <asp:LinkButton ID="btnToggleTermTypePanel" runat="server" Text="Term Types" onclick="toggleTermTypePanel"  CssClass="LinkButton" />
         </asp:TableHeaderCell><asp:TableHeaderCell Width="100">
            <asp:LinkButton ID="btnToggleTermPanel" runat="server" Text="Terms" onclick="toggleTermPanel"  CssClass="LinkButton" />
         </asp:TableHeaderCell><asp:TableHeaderCell Width="100">
            <asp:LinkButton ID="btnToggleCourseTypePanel" runat="server" Text="Fields" onclick="toggleCourseTypePanel"  CssClass="LinkButton" />
         </asp:TableHeaderCell><asp:TableHeaderCell Width="100">
            <asp:LinkButton ID="btnToggleClassPanel" runat="server" Text="Courses" onclick="toggleCoursePanel"  CssClass="LinkButton" />
         </asp:TableHeaderCell><asp:TableHeaderCell Width="100">
            <asp:LinkButton ID="btnToggleSection" runat="server" Text="Sections" onclick="toggleSectionPanel"  CssClass="LinkButton" />
         </asp:TableHeaderCell></asp:TableRow></asp:Table><asp:Panel ID="pnlTermType" runat="server" Visible="false">
      <asp:ListView 
         ID="lvTermType" runat="server" DataSourceID="dsAllTermTypes" 
         DataKeyNames="term_type_id" OnItemDataBound="checkDeletedTermType" 
         onitemupdating="termTypeUpdating"><LayoutTemplate>
         <div class="actionListMid">
            <table border="1" cellpadding="1" style="background-color:#DDDDDD" class="actionListLeft">
               <tr style="background-color:#E5E5FE">
                  <th colspan="3">
                     <asp:Label ID="lblTermTypeLV" runat="server" Text="Term Types" />
                  </th>
               </tr>
               <tr id="itemPlaceholder" runat="server"></tr>
            </table>
         <div>
         </LayoutTemplate>
         <ItemTemplate>
            <tr>
               <td id="termTypeName" runat="server"><asp:Label runat="server" ID="lblTermName"><%#Eval("term_type_name")%></asp:Label><asp:HiddenField ID="TermTypeMaint" runat="server" value='<%#Eval("term_type_maint")%>' />
               </td>
               <td id="termTypeGetBig" runat="server">
                  <asp:LinkButton ID="btnTermTypeReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("term_type_id")%>' onclick="reactivateTermType" Visible="false" />
                  <asp:LinkButton ID="btnTermTypeEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="termTypeHideMe" runat="server"><asp:LinkButton ID="btnTermTypeDelete" runat="server" CommandName="Delete" Text="Delete" /></td>
            </tr>
         </ItemTemplate>
         <EditItemTemplate>
            <tr>
               <td><asp:TextBox ID="bxEditTermTypeName" runat="server" Text='<%# Bind("term_type_name") %>' />
               <asp:HiddenField ID="TermTypeMaint" runat="server" value='<%#Eval("term_type_maint")%>' /></td>
               <td><asp:LinkButton ID="btnUpdateEditTermType" runat="server" CommandName="Update" Text="Update" /></td>
               <td><asp:LinkButton ID="btnCancelEditTermType" runat="server" CommandName="Cancel" Text="Cancel" /></td>
            </tr>
         </EditItemTemplate>
         <AlternatingItemTemplate>
            <tr>
               <td id="termTypeName" runat="server"><asp:Label runat="server" ID="lblName"><%#Eval("term_type_name")%></asp:Label><asp:HiddenField ID="TermTypeMaint" runat="server" value='<%#Eval("term_type_maint")%>' />
               </td>
               <td id="termTypeGetBig" runat="server">
                  <asp:LinkButton ID="btnTermTypeReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("term_type_id")%>' onclick="reactivateTermType" Visible="false" />
                  <asp:LinkButton ID="btnTermTypeEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="termTypeHideMe" runat="server"><asp:LinkButton ID="btnTermTypeDelete" runat="server" CommandName="Delete" Text="Delete" /></td>
            </tr>
         </AlternatingItemTemplate>
      </asp:ListView>





      <asp:Table ID="tblTermType" runat="server" BackColor="#DDDDDD"  class="actionListRight">
         <asp:TableHeaderRow>
            <asp:TableHeaderCell ColumnSpan="2">
               <asp:Label runat="server" Text="Add a Term Type" />
            </asp:TableHeaderCell></asp:TableHeaderRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label runat="server" Text="Term Type Name" />
            </asp:TableCell><asp:TableCell>
               <asp:TextBox ID="bxAddTermTypeName" runat="server" Text="" />
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
            </asp:TableCell><asp:TableCell>
               <asp:Button ID="btnAddTermType" runat="server" Text="Add" onclick="addTermType"/>
            </asp:TableCell></asp:TableRow></asp:Table><asp:Label ID="lblErrorAddTermType" runat="server" Text="" SkinID="InfoMessage"/>
   </asp:Panel>
   <asp:Panel ID="pnlTerm" runat="server" Visible="false">








      <asp:ListView 
         ID="lvTerm" runat="server"  DataSourceID="dsAllTerms" DataKeyNames="term_id" 
         OnItemDataBound="checkTerm" onitemupdating="termUpdating"><LayoutTemplate>
            <table border="1" cellpadding="1" style="background-color:#DDDDDD" class="actionListLeft">
               <tr style="background-color:#E5E5FE">
                  <th colspan="5">
                     <asp:Label ID="lblTermLV" runat="server" Text="Terms" />
                  </th>
               </tr>
               <tr id="itemPlaceholder" runat="server"></tr>
            </table>
         </LayoutTemplate>
         <ItemTemplate>
            <tr>
               <td id="termTermTypeName" runat="server">
                  <asp:Label runat="server" ID="lblTermName" Text='<%#Eval("term_type_name")%>' />
                  <asp:HiddenField ID="TermMaint" runat="server" value='<%#Eval("term_maint")%>' />
               </td>
               <td id="termStartDate" runat="server">
                  <asp:Label ID="lblTermStartDate" runat="server" Text='<%#Eval("term_start")%>' />
               </td>
               <td id="termEndDate" runat="server">
                  <asp:Label ID="lblTermEndDate" runat="server" Text='<%#Eval("term_end")%>' />
               </td>
               <td id="termGetBig" runat="server">
                  <asp:LinkButton ID="btnTermReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("term_id")%>' onclick="reactivateTerm" Visible="false" />
                  <asp:LinkButton ID="btnTermEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="termHideMe" runat="server">
                  <asp:LinkButton ID="btnTermDelete" runat="server" CommandName="Delete" Text="Delete" />
                  <asp:Label ID="lblCurrent" runat="server" Text="Current" Visible="false" />
               </td>
            </tr>
         </ItemTemplate>
         <EditItemTemplate>
            <tr>
               <td>
                  <asp:HiddenField ID="hfTermTypeID" runat="server" Value='<%#Eval("term_type_id") %>'/>
                  <asp:SqlDataSource ID="dsTermTypes" runat="server"
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT term_type_name, term_type_id
                                       FROM term_type 
                                      WHERE term_type_maint NOT LIKE 'D'
                               UNION SELECT term_type_name, term_type_id
                                       FROM term_type 
                                      WHERE term_type_id = :p_TermTypeID">
                     <SelectParameters>
                        <asp:ControlParameter Name="p_TermTypeID" ControlID="hfTermTypeID" PropertyName="Value" />
                     </SelectParameters>
                  </asp:SqlDataSource>
                  <asp:DropDownList ID="ddlEditTermType" runat="server"
                                    DataSourceID="dsTermTypes" DataTextField="term_type_name" 
                                    DataValueField="term_type_id" AppendDataBoundItems="True" 
                                    DataTextFormatString="{0}" Font-Names="Bitstream Vera Sans Mono" 
                                    SelectedValue='<%# Bind("term_type_id") %>'>
                  </asp:DropDownList>
                  <asp:HiddenField ID="TermMaint" runat="server" value='<%#Eval("term_maint")%>' /></td>
               <td>
                  <asp:TextBox ID="bxEditStartDate" runat="server" Text='<%# Bind("term_start") %>'  width="10ex"/>
                  <asp:CalendarExtender ID="CalendarExtenderEditStart" runat="server" TargetControlID="bxEditStartDate" Format="MM/dd/yyyy" OnInit="setStart">
                  </asp:CalendarExtender>
               </td>
               <td>
                  <asp:TextBox ID="bxEditEndDate" runat="server" Text='<%# Bind("term_end") %>'  width="10ex"/>
                  <asp:CalendarExtender ID="CalendarExtenderEditEnd" runat="server" TargetControlID="bxEditEndDate" Format="MM/dd/yyyy" OnInit="setStart">
                  </asp:CalendarExtender>
               </td>
               <td><asp:LinkButton ID="btnUpdateEditTerm" runat="server" CommandName="Update" Text="Update" /></td>
               <td><asp:LinkButton ID="btnCancelEditTerm" runat="server" CommandName="Cancel" Text="Cancel" /></td>
            </tr>
         </EditItemTemplate>
         <AlternatingItemTemplate>
            <tr>
               <td id="termTermTypeName" runat="server">
                  <asp:Label runat="server" ID="lblTermName" Text='<%#Eval("term_type_name")%>' />
                  <asp:HiddenField ID="TermMaint" runat="server" value='<%#Eval("term_maint")%>' />
               </td>
               <td id="termStartDate" runat="server">
                  <asp:Label ID="lblTermStartDate" runat="server" Text='<%#Eval("term_start")%>' />
               </td>
               <td id="termEndDate" runat="server">
                  <asp:Label ID="lblTermEndDate" runat="server" Text='<%#Eval("term_end")%>' />
               </td>
               <td id="termGetBig" runat="server">
                  <asp:LinkButton ID="btnTermReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("term_id")%>' onclick="reactivateTerm" Visible="false" />
                  <asp:LinkButton ID="btnTermEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="termHideMe" runat="server">
                  <asp:LinkButton ID="btnTermDelete" runat="server" CommandName="Delete" Text="Delete" />
                  <asp:Label ID="lblCurrent" runat="server" Text="Current" Visible="false" />
               </td>
            </tr>
         </AlternatingItemTemplate>
      </asp:ListView>








      <asp:Table ID="tblTerm" runat="server" BackColor="#DDDDDD" class="actionListRight">
         <asp:TableHeaderRow>
            <asp:TableHeaderCell ColumnSpan="2">
               <asp:Label runat="server" Text="Add a Term" />
            </asp:TableHeaderCell></asp:TableHeaderRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblTermType" runat="server" Text="Term Type: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:DropDownList ID="ddlTermType" runat="server" 
                                 DataSourceID="dsTermType" DataTextField="term_type_name" 
                                 DataValueField="term_type_id" AppendDataBoundItems="True" 
                                 DataTextFormatString="{0}" Font-Names="Bitstream Vera Sans Mono"
                                 Enabled="true">
               </asp:DropDownList>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblBeginDate" runat="server" Text="Begin Date: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:TextBox  ID="bxStartDate" runat="server" width="10ex"></asp:TextBox>
               <asp:CalendarExtender ID="CalendarExtenderStart" runat="server" TargetControlID="bxStartDate" Format="MM/dd/yyyy" OnInit="setStart">
               </asp:CalendarExtender>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblEndDate" runat="server" Text="End Date: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:TextBox  ID="bxEndDate" runat="server" width="10ex"></asp:TextBox>
               <asp:CalendarExtender ID="CalendarExtenderEnd" runat="server" TargetControlID="bxEndDate" Format="MM/dd/yyyy" OnInit="setStart">
               </asp:CalendarExtender>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell></asp:TableCell><asp:TableCell>
               <asp:Button ID="btnAddTerm" runat="server" Text="Add" OnClick="addTerm"/>
            </asp:TableCell></asp:TableRow></asp:Table>
      <asp:Label ID="lblErrorAddTerm" runat="server" Text="" SkinID="InfoMessage"/></asp:Panel><asp:Panel ID="pnlCourseType" runat="server" Visible="false">
      




      <asp:ListView 
         ID="lvCourseType" runat="server"  DataSourceID="dsAllCourseTypes" DataKeyNames="course_type_id" 
         OnItemDataBound="checkCourseType" onitemupdating="courseTypeUpdating"><LayoutTemplate>
            <table border="1" cellpadding="1" style="background-color:#DDDDDD" class="actionListLeft">
               <tr style="background-color:#E5E5FE">
                  <th colspan="4">
                     <asp:Label ID="lblCourseTypeLV" runat="server" Text="Fields" />
                  </th>
               </tr>
               <tr id="itemPlaceholder" runat="server"></tr>
            </table>
         </LayoutTemplate>
         <ItemTemplate>
            <tr>
               <td id="courseTypePrefix" runat="server">
                  <asp:Label ID="lblCourseTypePrefix" runat="server" Text='<%#Eval("course_type_prefix")%>' />
               </td>
               <td id="courseTypeName" runat="server">
                  <asp:Label runat="server" ID="lblTermName" Text='<%#Eval("course_type_name")%>' />
                  <asp:HiddenField ID="hdCourseTypeMaint" runat="server" value='<%#Eval("course_type_maint")%>' />
               </td>
               <td id="courseTypeGetBig" runat="server">
                  <asp:LinkButton ID="btnCourseTypeReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("course_type_id")%>' onclick="reactivateCourseType" Visible="false" />
                  <asp:LinkButton ID="btnCourseTypeEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="CourseTypeHideMe" runat="server"><asp:LinkButton ID="btnCourseTypeDelete" runat="server" CommandName="Delete" Text="Delete" /></td>
            </tr>
         </ItemTemplate>
         <EditItemTemplate>
            <tr>
               <td>
                  <asp:TextBox ID="bxEditCoursePrefix" runat="server" Width="5ex" MaxLength="2" Text='<%#Bind("course_type_prefix")%>'/>
                  <asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="bxEditCoursePrefix" FilterType="UppercaseLetters,LowercaseLetters" />
                  <asp:HiddenField ID="hdCourseTypeMaint" runat="server" value='<%#Eval("course_type_maint")%>' /></td>
               <td>
                  <asp:TextBox  ID="bxCourseTypeName" runat="server" width="15ex" MaxLength="20" Text='<%#Bind("course_type_name")%>'/>
               </td>
               <td><asp:LinkButton ID="btnUpdateEditCourseType" runat="server" CommandName="Update" Text="Update" /></td>
               <td><asp:LinkButton ID="btnCancelEditCourseType" runat="server" CommandName="Cancel" Text="Cancel" /></td>
            </tr>
         </EditItemTemplate>
         <AlternatingItemTemplate>
            <tr>
               <td id="courseTypePrefix" runat="server">
                  <asp:Label ID="lblCourseTypePrefix" runat="server" Text='<%#Eval("course_type_prefix")%>' />
               </td>
               <td id="courseTypeName" runat="server">
                  <asp:Label runat="server" ID="lblCourseTypeName" Text='<%#Eval("course_type_name")%>' />
                  <asp:HiddenField ID="hdCourseTypeMaint" runat="server" value='<%#Eval("course_type_maint")%>' />
               </td>
               <td id="courseTypeGetBig" runat="server">
                  <asp:LinkButton ID="btnCourseTypeReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("course_type_id")%>' onclick="reactivateCourseType" Visible="false" />
                  <asp:LinkButton ID="btnCourseTypeEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="CourseTypeHideMe" runat="server"><asp:LinkButton ID="btnCourseTypeDelete" runat="server" CommandName="Delete" Text="Delete" /></td>
            </tr>
         </AlternatingItemTemplate>
      </asp:ListView>









      <asp:Table ID="tblCourseType" runat="server" BackColor="#DDDDDD" class="actionListRight">
         <asp:TableHeaderRow>
            <asp:TableHeaderCell ColumnSpan="2">
               <asp:Label runat="server" Text="Add a Field" />
            </asp:TableHeaderCell></asp:TableHeaderRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblCoursePrefix" runat="server" Text="Prefix: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:TextBox ID="bxCoursePrefix" runat="server" Width="5ex" MaxLength="2" />
               <asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="bxCoursePrefix" FilterType="UppercaseLetters,LowercaseLetters" >
               </asp:FilteredTextBoxExtender>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblCourseTypeName" runat="server" Text="Field Name: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:TextBox  ID="bxCourseTypeName" runat="server" width="15ex" MaxLength="20" />
            </asp:TableCell></asp:TableRow><asp:TableRow>
      <asp:TableCell>
      </asp:TableCell><asp:TableCell><asp:Button ID="btnAddCourseType" runat="server" Text="Add" OnClick="addCourseType" />
      </asp:TableCell></asp:TableRow></asp:Table><asp:Label ID="lblErrorAddCourseType" runat="server" Text="" SkinID="InfoMessage"/></asp:Panel><asp:Panel ID="pnlCourse" runat="server" Visible="false">
      
      












      <asp:ListView 
         ID="lvCourse" runat="server"  DataSourceID="dsAllCourses" DataKeyNames="course_id" 
         OnItemDataBound="checkCourse" onitemupdating="courseUpdating">
         <LayoutTemplate>
            <table border="1" cellpadding="1" style="background-color:#DDDDDD" class="actionListLeft">
               <tr style="background-color:#E5E5FE">
                  <th colspan="5">
                     <asp:Label ID="lblCourseLV" runat="server" Text="Courses" />
                  </th>
               </tr>
               <tr id="itemPlaceholder" runat="server"></tr>
            </table>
         </LayoutTemplate>
         <ItemTemplate>
            <tr>
               <td id="courseTypePrefix" runat="server">
                  <asp:Label ID="lblCourseTypePrefix" runat="server" Text='<%#Eval("course_type_prefix")%>' />
               </td>
               <td id="courseNumber" runat="server">
                  <asp:Label ID="lblCourseNumber" runat="server" Text='<%#Eval("course_number")%>' />
               </td>
               <td id="courseName" runat="server">
                  <asp:Label runat="server" ID="lblCourseName" Text='<%#Eval("course_name")%>' />
                  <asp:HiddenField ID="hdCourseMaint" runat="server" value='<%#Eval("course_maint")%>' />
               </td>
               <td id="courseGetBig" runat="server">
                  <asp:LinkButton ID="btnCourseReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("course_id")%>' onclick="reactivateCourse" Visible="false" />
                  <asp:LinkButton ID="btnCourseEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="CourseHideMe" runat="server"><asp:LinkButton ID="btnCourseDelete" runat="server" CommandName="Delete" Text="Delete" /></td>
            </tr>
         </ItemTemplate>
         <EditItemTemplate>
            <tr>
               <td>
                  <asp:HiddenField ID="hdCourseID" runat="server" Value='<%#Eval("course_type_id") %>'/>
                  <asp:SqlDataSource ID="dsCourses" runat="server"
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT course_type_prefix, course_type_id
                                       FROM course_type 
                                      WHERE course_type_maint NOT LIKE 'D'
                               UNION SELECT course_type_prefix, course_type_id
                                       FROM course_type
                                      WHERE course_type_id =:p_CourseTypeID">
                     <SelectParameters>
                        <asp:ControlParameter Name="p_CourseTypeID" ControlID="hdCourseID" PropertyName="Value" />
                     </SelectParameters>
                  </asp:SqlDataSource>
                  <asp:DropDownList ID="ddlEditCoursePrefix" runat="server" AppendDataBoundItems="True" 
                                    DataTextFormatString="{0}" DataSourceID="dsCourses" DataTextField="course_type_prefix" 
                                    DataValueField="course_type_id" Font-Names="Bitstream Vera Sans Mono" 
                                    SelectedValue='<%# Bind("course_type_id") %>'>
                  </asp:DropDownList>
                  <asp:HiddenField ID="hdCourseMaint" runat="server" value='<%#Eval("course_maint")%>' />
               </td>
               <td>
                  <asp:TextBox ID="bxEditcourseNumber" runat="server" Width="15ex" MaxLength="3" Text='<%#Bind("course_number")%>' />
                  <asp:FilteredTextBoxExtender ID="FilteredTextBoxExtenderLVEdit" runat="server" TargetControlID="bxEditcourseNumber" FilterType="Custom" ValidChars="1234567890" />
               </td>
               <td>
                  <asp:TextBox  ID="bxCourseName" runat="server" width="15ex" MaxLength="20" Text='<%#Bind("course_name")%>'/>
               </td>
               <td><asp:LinkButton ID="btnUpdateEditCourse" runat="server" CommandName="Update" Text="Update" /></td>
               <td><asp:LinkButton ID="btnCancelEditCourse" runat="server" CommandName="Cancel" Text="Cancel" /></td>
            </tr>
         </EditItemTemplate>
         <AlternatingItemTemplate>
            <tr>
               <td id="courseTypePrefix" runat="server">
                  <asp:Label ID="lblCourseTypePrefix" runat="server" Text='<%#Eval("course_type_prefix")%>' />
               </td>
               <td id="courseNumber" runat="server">
                  <asp:Label ID="lblCourseNumber" runat="server" Text='<%#Eval("course_number")%>' />
               </td>
               <td id="courseName" runat="server">
                  <asp:Label runat="server" ID="lblCourseName" Text='<%#Eval("course_name")%>' />
                  <asp:HiddenField ID="hdCourseMaint" runat="server" value='<%#Eval("course_maint")%>' />
               </td>
               <td id="courseGetBig" runat="server">
                  <asp:LinkButton ID="btnCourseReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("course_id")%>' onclick="reactivateCourse" Visible="false" />
                  <asp:LinkButton ID="btnCourseEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="CourseHideMe" runat="server"><asp:LinkButton ID="btnCourseDelete" runat="server" CommandName="Delete" Text="Delete" /></td>
            </tr>
         </AlternatingItemTemplate>
      </asp:ListView>










































      <asp:Table ID="tblCourse" runat="server" BackColor="#DDDDDD" class="actionListRight" >
         <asp:TableHeaderRow>
            <asp:TableHeaderCell ColumnSpan="2">
               <asp:Label runat="server" Text="Add a Course" />
            </asp:TableHeaderCell></asp:TableHeaderRow><asp:TableRow>
            <asp:TableCell ColumnSpan="2">
               <asp:Label ID="lblCourseTypeSlct" runat="server" Text="Course Type: "></asp:Label>
               <br />
               <asp:DropDownList ID="ddlAddCourseCourseType" runat="server"
                              DataSourceID="dsCoursePrefix" DataTextField="course_desc" 
                              DataValueField="course_type_id" AppendDataBoundItems="True" 
                              DataTextFormatString="{0}" Font-Names="Bitstream Vera Sans Mono">
               </asp:DropDownList>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblCourseNumber" runat="server" Text="Course Number: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:TextBox  ID="bxCourseNumber" runat="server" width="10ex" MaxLength="3" />
               <asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="bxCourseNumber" FilterType="Custom" ValidChars="1234567890" />
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblCourseName" runat="server" Text="Course Name: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:TextBox  ID="bxCourseName" runat="server" width="10ex"></asp:TextBox>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
            </asp:TableCell><asp:TableCell>
               <asp:Button ID="btnAddCourse" runat="server" Text="Add" OnClick="addCourse"/>
            </asp:TableCell></asp:TableRow></asp:Table><asp:Label ID="lblErrorAddClass" runat="server" Text="" SkinID="InfoMessage"/></asp:Panel><asp:Panel id="pnlSection" runat="server" Visible="false">

      



      <asp:ListView ID="lvSection" runat="server"  DataSourceID="dsAllSections" DataKeyNames="section_id" 
                          OnItemDataBound="checkSection" OnItemUpdating="sectionUpdating">
         <LayoutTemplate>
            <table border="1" cellpadding="1" style="background-color:#DDDDDD" class="actionListLeftCustom">
               <tr style="background-color:#E5E5FE">
                  <th colspan="5">
                     <asp:Label ID="lblSectionLV" runat="server" Text="Sections" />
                  </th>
               </tr>
               <tr id="itemPlaceholder" runat="server"></tr>
            </table>
         </LayoutTemplate>
         <ItemTemplate>
            <tr>
               <td id="sectionTerm" runat="server">
                  <asp:Label runat="server" ID="lblSectionTerm" Text='<%#Eval("term")%>' />
                  <asp:HiddenField ID="hdSectionMaint" runat="server" value='<%#Eval("section_maint")%>' />
                  <asp:HiddenField ID="hdTermEnd" runat="server" value='<%#Eval("term_end_date")%>' />
               </td>
               <td id="sectionCourseFancy" runat="server">
                  <asp:Label ID="lblSectionCourseFancy" runat="server" Text='<%#Eval("course_fancy")%>' />
               </td>
               <td id="sectionTeacher" runat="server">
                  <asp:Label ID="lblSectionTeacher" runat="server" Text='<%#Eval("name")%>' />
               </td>
               <td id="sectionGetBig" runat="server">
                  <asp:LinkButton ID="btnSectionReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("section_id")%>' onclick="reactivateSection" Visible="false" />
                  <asp:LinkButton ID="btnSectionEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="sectionHideMe" runat="server"><asp:LinkButton ID="btnSectionDelete" runat="server" CommandName="Delete" Text="Delete" /></td>
            </tr>
         </ItemTemplate>
         <EditItemTemplate>
            <tr>
               <td id="SectionTerm" runat="server">
                  <asp:Label runat="server" ID="lblSectionTerm" Text='<%#Eval("term")%>' />
                  <asp:HiddenField ID="hdSectionMaint" runat="server" value='<%#Eval("section_maint")%>' />
                  <asp:HiddenField ID="hdTermEnd" runat="server" value='<%#Eval("term_end_date")%>' />
               </td>
               <td id="sectionCourseFancy" runat="server">
                  <asp:Label ID="lblSectionCourseFancy" runat="server" Text='<%#Eval("course_fancy")%>' />
               </td>
               <td id="sectionTeacher" runat="server">
                  <asp:HiddenField ID="hdSectionID" runat="server" Value='<%#Eval("section_id")%>'/>
                  <asp:SqlDataSource ID="dsTeachers" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                      ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      SelectCommand="SELECT user_id, user_first_name || ' ' || user_last_name as name 
                                       FROM testify_user 
                                      WHERE user_type_id = 2
                                        AND user_maint NOT LIKE 'D'
                               UNION SELECT user_id, user_first_name || ' ' || user_last_name as name 
                                       FROM testify_user
                                       JOIN section
                                         ON section.teacher_id = testify_user.user_id
                                       WHERE section.section_id = :p_SectionID" >
                     <SelectParameters>
                        <asp:ControlParameter Name="p_SectionID" ControlID="hdSectionID" PropertyName="Value" />
                     </SelectParameters>
                  </asp:SqlDataSource>
                  <asp:DropDownList ID="ddlEditTeacher" runat="server" 
                                 DataSourceID="dsTeachers" DataTextField="name" 
                                 DataValueField="user_id" AppendDataBoundItems="true" 
                                 DataTextFormatString="{0}" Font-Names="Bitstream Vera Sans Mono"
                                 CssClass="dropDownSection" SelectedValue='<%#Bind("user_id")%>'>
               </asp:DropDownList>
               </td>
               <td><asp:LinkButton ID="btnUpdateEditSection" runat="server" CommandName="Update" Text="Update" /></td>
               <td><asp:LinkButton ID="btnCancelEditSection" runat="server" CommandName="Cancel" Text="Cancel" /></td>
            </tr>
         </EditItemTemplate>
         <AlternatingItemTemplate>
            <tr>
               <td id="sectionTerm" runat="server">
                  <asp:Label runat="server" ID="lblSectionTerm" Text='<%#Eval("term")%>' />
                  <asp:HiddenField ID="hdSectionMaint" runat="server" value='<%#Eval("section_maint")%>' />
                  <asp:HiddenField ID="hdTermEnd" runat="server" value='<%#Eval("term_end_date")%>' />
               </td>
               <td id="sectionCourseFancy" runat="server">
                  <asp:Label ID="lblSectionCourseFancy" runat="server" Text='<%#Eval("course_fancy")%>' />
               </td>
               <td id="sectionTeacher" runat="server">
                  <asp:Label ID="lblSectionTeacher" runat="server" Text='<%#Eval("name")%>' />
               </td>
               <td id="sectionGetBig" runat="server">
                  <asp:LinkButton ID="btnSectionReactivate" runat="server" Text="Reactivate" CommandArgument='<%#Eval("section_id")%>' onclick="reactivateSection" Visible="false" />
                  <asp:LinkButton ID="btnSectionEdit" runat="server" CommandName="Edit" Text="Edit" />
               </td>
               <td id="sectionHideMe" runat="server"><asp:LinkButton ID="btnSectionDelete" runat="server" CommandName="Delete" Text="Delete" /></td>
            </tr>
         </AlternatingItemTemplate>
      </asp:ListView>




      <asp:Table ID="tblSection" runat="server" BackColor="#DDDDDD" class="actionListRight">
         <asp:TableHeaderRow>
            <asp:TableHeaderCell ColumnSpan="2">
               <asp:Label runat="server" Text="Add a Section" />
            </asp:TableHeaderCell></asp:TableHeaderRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblSectionsTermSelect" runat="server" Text="Term: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:DropDownList ID="ddlTerm" runat="server" 
                                 DataSourceID="dsTerm" DataTextField="term_desc" 
                                 DataValueField="term_id" AppendDataBoundItems="True" 
                                 DataTextFormatString="{0}" Font-Names="Bitstream Vera Sans Mono"
                                 CssClass="dropDownSection">
               </asp:DropDownList>
            </asp:TableCell></asp:TableRow><asp:TableRow>
         
            <asp:TableCell>
               <asp:Label ID="lblSectionsCourseTypeSelect" runat="server" Text="Field: " />
            </asp:TableCell><asp:TableCell>
            <asp:UpdatePanel runat="server" ID="update1">
         <ContentTemplate>
               <asp:DropDownList ID="ddlCourseType" runat="server"
                                 DataSourceID="dsCoursePrefix" DataTextField="course_desc" 
                                 DataValueField="course_type_id" AppendDataBoundItems="True" 
                                 DataTextFormatString="{0}" Font-Names="Bitstream Vera Sans Mono" 
                                 onselectedindexchanged="loadCourseList" AutoPostBack="true"
                                 CssClass="dropDownSection">
               </asp:DropDownList>
         </ContentTemplate>
         </asp:UpdatePanel>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblSectionsCourseSelect" runat="server" Text="Course: "></asp:Label>
            </asp:TableCell><asp:TableCell>
         <asp:UpdatePanel runat="server" ID="update2">
         <ContentTemplate>
               <asp:DropDownList ID="ddlCourseName" runat="server" 
                                 DataSourceID="dsCourseName" DataTextField="course_desc" 
                                 DataValueField="course_id" AppendDataBoundItems="true" 
                                 DataTextFormatString="{0}" Font-Names="Bitstream Vera Sans Mono"
                                 Enabled="false" CssClass="dropDownSection">
               </asp:DropDownList>
         </ContentTemplate>
         </asp:UpdatePanel>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
               <asp:Label ID="lblSectionsTeacherSelect" runat="server" Text="Teacher: "></asp:Label>
            </asp:TableCell><asp:TableCell>
               <asp:DropDownList ID="ddlTeacher" runat="server" 
                                 DataSourceID="dsTeacher" DataTextField="name" 
                                 DataValueField="u_id" AppendDataBoundItems="true" 
                                 DataTextFormatString="{0}" Font-Names="Bitstream Vera Sans Mono"
                                 CssClass="dropDownSection">
               </asp:DropDownList>
            </asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
            </asp:TableCell><asp:TableCell>
               <asp:Button ID="btnAddSection" runat="server" Text="Add" OnClick="addSection"/>
            </asp:TableCell></asp:TableRow></asp:Table><asp:Label ID="lblErrorAddSection" runat="server" Text="" SkinID="InfoMessage" /></asp:Panel></asp:Content>